package com.lc.afbx.adapters;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.view.SimpleDraweeView;
import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.conn.GetApiShowCompany;
import com.zcx.helper.util.UtilLog;

import java.util.List;

/**
 * Created by Administrator on 2016/5/27.
 */
public class HeZuoAdapter extends BaseAdapter {

    private final LayoutInflater inflater;
    private List<GetApiShowCompany.Data> data;

    public HeZuoAdapter(Context context, List<GetApiShowCompany.Data> data) {
        inflater = LayoutInflater.from(context);
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {


        ViewHolder holder = null;
        if (convertView == null) {

            convertView = inflater.inflate(R.layout.item_hezuogognsi_gridview, null);
            convertView = BaseApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);

            holder = new ViewHolder();
            holder.img = (SimpleDraweeView) convertView.findViewById(R.id.item_gridview_hezuogongsi);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        UtilLog.e("合作公司adapter", "data.get(position).picurl" + data.get(position).picurl);
//        BaseApplication.UtilAsyncListBitmap.get(data.get(position).picurl, holder.img, R.mipmap.hezuogongsi);

        holder.img.setImageURI(Uri.parse(data.get(position).picurl));
        return convertView;
    }

    class ViewHolder {
        SimpleDraweeView img;
    }
}
